#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
const int N = 2020;
int a[N], n;
vector<int> mp[N];


int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        if (a[i] > 0)
            for (int t = i + 1; t <= n && t <= i + a[i]; ++t)
                mp[i].push_back(t);
        else
            for (int t = max(0, i + a[i]); t >= 0; --t)
                mp[i].push_back(t);
    }
    int dist[N] = { 0 };
    memset(dist, -1, sizeof dist);
    queue<int> q;
    q.push(1);
    dist[1] = 0;
    while (q.size())
    {
        int t = q.front();
        q.pop();
        for (auto e : mp[t])
            if (dist[e] == -1)
            {
                dist[e] = dist[t] + 1;
                if (e == n)
                    break;
                q.push(e);
            }
    }
    cout << dist[n] << endl;
    return 0;
}